<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件委托</title>
    <style>
        ul,li{
            padding:0;
            margin:0;
            list-style:none;
        }
        ul{
            width: 500px;
            height: 500px;
            margin: 20px auto;
            display: flex;
            font-size: 20px;
            justify-content: center;
            background: lightseagreen;
        }
        li{
            width: 100px;
            height: 100px;
            margin-right: 50px;
            background: pink;
            margin-top: 20px;
            text-align: center;
            line-height: 100px;
        }
    </style>
</head>
<body>
<ul>
    <li>li</li>
    <li>li</li>
    <li>li</li>
</ul>
<script>
    //获取元素
    const ul = document.querySelector('ul');

    //将点击事件绑定ul标签上
    ul.onclick = function (e) {
        // console.log('我被点击了')
        // console.log(e.target)//获取被点击的准确目标

        //判断点击目标的标签名是否等于li
        if (e.target.tagName==='LI'){   //tagName是目标标签名是的名称，全等号右边的标签名是大写
            console.log('我点击的是li')
        }
    }
</script>
</body>
</html>